<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>下面代码解决了什么问题</title>
</head>
<body>
<script>
    var myString = 'This sentence has has a fault and and we need to fix it.';
    var myRegExp = /(\b\w+\b) \1/g;
    myString = myString.replace(myRegExp, '$1');
    document.write(myString);

    myString = 'This sentence has has a fault and and we need to fix it.';
    myRegExp = new RegExp('(\\b\w+\\b) \\1', 'g');
    myString = myString.replace(myRegExp, '$1');
    document.write(myString);
</script>
</body>
</html>